﻿//INNOVACALL FRAMEWORK MUST BE IN ALL VIEW JAVASCRIPT
$.fn.DocReady = function () {
    var dataSource = $.fn.ConfigureDataSource();
    $.fn.ConfigureGrid(dataSource);
}

$.fn.ConfigureDataSource = function () {
    var dataSource = new kendo.data.DataSource({
        transport: {
            read: { url: "/Logs/XmlContent.xml", dataType: "xml" }
        },
        schema: {
            type: "xml",
            data: "/events/event",
            model: {
                fields: {
                    logger: "@logger",
                    level: "@level",
                    time: "@timestamp",
                    username: "@identity",
                    message: "message/text()",
                    propertiesname: "properties/data/@name",
                    propertiesvalue: "properties/data/@value"

                }
            }
        },
        pageSize: 10
    });
    return dataSource;
}

$.fn.ConfigureGrid = function (datasource) {
    $("#grid").kendoGrid({
        dataSource: datasource,
        height: 430,
        filterable: true,
        sortable: true,
        scrollable: true,
        pageable: { messages: { display: "{0:d0} " + cap_KendoUIGrid_Pageable_To + " {1:d0} " + cap_KendoUIGrid_Pageable_Of + " {2:d0} " + cap_KendoUIGrid_Pageable_Elements } },
        groupable: true,
        columns: [
            {
                field: "time",
                title: cap_GridColumn_Time,
                width: 50
            },
            {
                field: "level",
                title: cap_GridColumn_Level,
                width: 50
            },
            {
                field: "message",
                title: cap_GridColumn_Message,
                width: 250
            },
            {
                field: "logger",
                title: cap_GridColumn_Logger,
                width: 50
            },
            {
                field: "username",
                title: cap_GridColumn_UserName,
                width: 50
            },
            //{
            //    template: "#= propertiesname + ' : ' + propertiesvalue #",
            //    title: cap_GridColumn_Properties,
            //    width: 50
            //}
        ]
    });
}